package com.yonyou.pmclouds.pmpub;

import com.yonyou.pmclouds.pmpub.rmiitf.IPageQuerySerivce;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class PageQueryConfiguration implements BeanPostProcessor {

    private CommonQuerySerivceImp commonQuerySerivceImp = new CommonQuerySerivceImp();

    @Bean
    public CommonQuerySerivceImp commonQuerySerivceImp() {
        return commonQuerySerivceImp;
    }

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if(bean instanceof IPageQuerySerivce){
            IPageQuerySerivce service = ((IPageQuerySerivce)bean);
            commonQuerySerivceImp.putBuziQuerInfo(service);
        }
        return bean;
    }
}
